version 14.0
set more off
capture log close
clear 
log using Schafheitle_et_al_2019_analyse, replace
set dp comma

*****************************************************************************************
*Schafheitle, Weibel, Meidert & Leuffen (2019)
*****************************************************************************************

*Data set
clear
*cd ...*
use Schafheitle_et_al_2019_data

*-77 and -99 = Missing
foreach v of varlist v_83- v_420 {
replace `v'=. if `v'==-77
replace `v'=. if `v'==-99
}

foreach v of varlist v_12- v_20 {
replace `v'=. if `v'==-77
replace `v'=. if `v'==-99
}

foreach v of varlist v_34- v_82 {
replace `v'=. if `v'==-77
replace `v'=. if `v'==-99
}

*Recode / reverse items disposition to trust 
generate trustdisp1 = 7+1-v_12
tab trustdisp1 v_12
generate trustdisp2 = v_13
generate trustdisp3 = 7+1-v_14
generate trustdisp4 = v_15
generate trustdisp5 = 7+1-v_16
generate trustdisp6 = v_17
generate trustdisp7 = v_18
generate trustdisp8 = v_20

*Rename vignette variables
rename v_83 trusttax1
rename v_84 trustg11
rename v_85 trustg21
rename v_86 trustg31
rename v_95 trustc11
rename v_96 trustc21
rename v_97 trustc31
rename v_223 trusttax2
rename v_331 trustg12
rename v_332 trustg22
rename v_333 trustg32
rename v_334 trustc12
rename v_335 trustc22
rename v_336 trustc32
rename v_230 trusttax3
rename v_337 trustg13
rename v_338 trustg23
rename v_339 trustg33
rename v_340 trustc13
rename v_341 trustc23
rename v_342 trustc33
rename v_244 trusttax4
rename v_343 trustg14
rename v_344 trustg24
rename v_345 trustg34
rename v_346 trustc14
rename v_347 trustc24
rename v_348 trustc34
rename v_237 trusttax5
rename v_349 trustg15
rename v_350 trustg25
rename v_351 trustg35
rename v_352 trustc15
rename v_353 trustc25
rename v_354 trustc35
rename v_251 trusttax6
rename v_355 trustg16
rename v_356 trustg26
rename v_357 trustg36
rename v_358 trustc16
rename v_359 trustc26
rename v_360 trustc36
rename v_258 trusttax7
rename v_361 trustg17
rename v_362 trustg27
rename v_363 trustg37
rename v_364 trustc17
rename v_365 trustc27
rename v_366 trustc37
rename v_265 trusttax8
rename v_367 trustg18
rename v_368 trustg28
rename v_369 trustg38
rename v_370 trustc18
rename v_371 trustc28
rename v_372 trustc38
rename v_272 trusttax9
rename v_373 trustg19
rename v_374 trustg29
rename v_375 trustg39
rename v_376 trustc19
rename v_377 trustc29
rename v_378 trustc39
rename v_279 trusttax10 
rename v_379 trustg110
rename v_380 trustg210
rename v_381 trustg310
rename v_382 trustc110
rename v_383 trustc210
rename v_384 trustc310
rename v_286 trusttax11
rename v_385 trustg111
rename v_386 trustg211
rename v_387 trustg311
rename v_388 trustc111
rename v_389 trustc211
rename v_390 trustc311
rename v_293 trusttax12
rename v_391 trustg112
rename v_392 trustg212
rename v_393 trustg312
rename v_394 trustc112
rename v_395 trustc212
rename v_396 trustc312
rename v_300 trusttax13
rename v_397 trustg113
rename v_398 trustg213
rename v_399 trustg313
rename v_400 trustc113
rename v_401 trustc213
rename v_402 trustc313
rename v_307 trusttax14
rename v_403 trustg114
rename v_404 trustg214
rename v_405 trustg314
rename v_406 trustc114
rename v_407 trustc214
rename v_408 trustc314
rename v_314 trusttax15
rename v_409 trustg115
rename v_410 trustg215
rename v_411 trustg315
rename v_412 trustc115
rename v_413 trustc215
rename v_414 trustc315
rename v_321 trusttax16
rename v_415 trustg116
rename v_416 trustg216
rename v_417 trustg316
rename v_418 trustc116
rename v_419 trustc216
rename v_420 trustc316

**********************************************************************************************************************

*Gender
generate mann= v_35-1
replace mann=. if mann==-1

*String to numeric / missings for age 
replace v_421="." if v_421=="-66" | v_421=="-99"
replace v_421="41" if v_421=="41 Jahre"
replace v_421="54" if v_421=="54 Jahre"
replace v_421="63" if v_421=="63 Jahre"
replace v_421="70" if v_421=="70 Jahre"
replace v_421="." if v_421=="xxxx"

encode v_421, generate(age)
generate age1=age/10


*Federal state
rename v_448 fedstate

*Oettinger 
generate bawue=1 if fedstate==1
replace bawue=0 if fedstate>1&fedstate<17

*Agriculture
generate agri=1 if fedstate==1|fedstate==2|fedstate==4|fedstate==9|fedstate==10
replace agri=0 if fedstate==3|fedstate==5|fedstate==6|fedstate==7|fedstate==8|fedstate==11|fedstate==12|fedstate==13|fedstate==14|fedstate==15|fedstate==16

*Imagine next sunday is election day ...
rename v_452 cducsu
rename v_453 fdp
rename v_454 spd
rename v_455 gruene
rename v_456 linke
rename v_457 sonstige

*Left / right
generate conservative=1 if cducsu==1|fdp==1
replace conservative=0 if spd==1|gruene==1|linke==1
replace conservative=. if sonstige==1

*Center
generate centrum=1 if cducsu==1|spd==1
replace centrum=0 if fdp==1|gruene==1|linke==1
replace centrum=. if sonstige==1

*Pro-EU
generate proeu=1 if v_77==1
replace proeu=0 if v_77==2

*Political interest
generate interest=1 if v_461>0&v_461<6
replace interest=0 if v_461>5&v_461<8

*Education
generate smart=1 if v_458>2&v_458<9
replace smart=0 if v_458==1| v_458==2|v_458==9

*Knwoledge about EU
rename v_78 know_1
rename v_79 know_2
rename v_80 know_3
generate know_3rev=1 if know_3==0
replace know_3rev=0 if know_3==1
rename v_81 know_4
rename v_82 know_5
generate know_5rev=1 if know_5==0
replace know_5rev=0 if know_5==1
generate knowkom=know_1+know_2+know_3rev+know_4+know_5rev

*TRUSTDISP
*Reliability
alpha trustdisp1 trustdisp2 trustdisp3 trustdisp4 trustdisp5 trustdisp6 trustdisp7 trustdisp8, detail item
generate TRUSTDISP=(trustdisp2+trustdisp3+trustdisp4+trustdisp6+trustdisp7+trustdisp8)/6

*Long format
generate id=_n
reshape long trusttax trustg1 trustg2 trustg3 trustc1 trustc2 trustc3, i(id) j(vignette)

*Including only complete cases
drop if dispcode==22
drop if trusttax==. & trustg1==. & trustg2==. & trustg3==. & trustc1==. & trustc2==. & trustc3==.

*Data mangeemnt trusttax
replace trusttax=. if trusttax==0

*Participation
generate particip=.
replace particip=1 if vignette==1|vignette ==2| vignette==3|vignette==4| vignette==5|vignette==6|vignette==7|vignette==8
replace particip=0 if vignette==9|vignette ==10| vignette==11|vignette==12| vignette==13|vignette==14|vignette==15|vignette==16

*Value congruence
generate valuecon=.
replace valuecon=1 if vignette==1|vignette ==2| vignette==3|vignette==4| vignette==9|vignette==10|vignette==11|vignette==12
replace valuecon=0 if vignette==5|vignette ==6| vignette==7|vignette==8| vignette==13|vignette==14|vignette==15|vignette==16

*Visibility
generate visibmeat=.
replace visibmeat=1 if vignette==1|vignette ==2| vignette==5|vignette==6| vignette==9|vignette==10|vignette==13|vignette==14
replace visibmeat=0 if vignette==3|vignette ==4| vignette==7|vignette==8| vignette==11|vignette==12|vignette==15|vignette==16

*Performance
generate performenergy=.
replace performenergy=1 if vignette==1|vignette ==3| vignette==5|vignette==7| vignette==9|vignette==11|vignette==13|vignette==15
replace performenergy=0 if vignette==2|vignette ==4| vignette==6|vignette==8| vignette==10|vignette==12|vignette==14|vignette==16

*EFA TRUST
factor trustg1 trustg2 trustg3 trustc1 trustc2 trustc3, pcf
rotate, promax 

factor trustg1 trustg2 trustg3 trustc1 trustc2 trustc3, pcf factor(2)
rotate, promax

*Reliability
alpha trustg1 trustg2 trustg3 trustc1 trustc2 trustc3, item
alpha trustc1 trustc2 trustc3, item
alpha trustg1 trustg2 trustg3, item

*GOODWILL
generate GOODWILL=(trustg1+trustg2+trustg3)/3

*COMPETENCE
generate COMPETENCE=(trustc1+trustc2+trustc3)/3

*TRUST
generate TRUST=(trustg1+trustg2+trustg3+trustc1+trustc2+trustc3)/6

**********
*Analyses*
**********

*Descriptives
corr TRUST trusttax particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom
sum TRUST trusttax particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom
sum TRUST trusttax particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom if TRUST!=. & trusttax !=. & particip!=. & valuecon!=. & visibmeat!=. & performenergy!=. & mann!=. & age1!=. & smart!=. & centrum!=. & agri!=. & TRUSTDISP!=. & interest!=. & proeu!=. & knowkom!=. 

*Regressions
regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 
regress trusttax particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 
regress trusttax TRUST mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 
regress trusttax TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 

regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 
ologit trusttax particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 
ologit trusttax TRUST mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 
ologit trusttax TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom, cluster (id) 

*Moderation 
generate participXknowkom = particip*knowkom
generate valueconXkonwkom = valuecon*knowkom
generate visibmeatXkonwkom = visibmeat*knowkom
generate performenergyXknowkom = performenergy*knowkom

regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom participXknowkom, cluster (id) 
regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom valueconXkonwkom, cluster (id)
regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom visibmeatXkonwkom, cluster (id) 
regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom performenergyXknowkom, cluster (id)  
regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu knowkom participXknowkom valueconXkonwkom visibmeatXkonwkom performenergyXknowkom, cluster (id) 

regress TRUST i.particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu c.knowkom i.particip#c.knowkom, cluster (id) 
regress TRUST particip i.valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu c.knowkom i.valuecon#c.knowkom, cluster (id)
regress TRUST particip valuecon i.visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu c.knowkom i.visibmeat#c.knowkom, cluster (id) 
regress TRUST particip valuecon visibmeat performenergy mann age1 smart centrum agri TRUSTDISP interest proeu c.knowkom i.performenergy#c.knowkom, cluster (id)  
regress TRUST particip valuecon visibmeat i.performenergy mann age1 smart centrum agri TRUSTDISP interest proeu c.knowkom i.particip#c.knowkom i.valuecon#c.knowkom i.visibmeat#c.knowkom i.performenergy#c.knowkom, cluster (id) 

*without controls
regress TRUST particip valuecon visibmeat performenergy, cluster (id) 
regress trusttax particip valuecon visibmeat performenergy, cluster (id) 
regress trusttax TRUST, cluster (id) 
regress trusttax TRUST particip valuecon visibmeat performenergy, cluster (id) 

log close
